﻿///////////////////////////////////////////////////////////////
// This is generated code. 
//////////////////////////////////////////////////////////////
// Code is generated using LLBLGen Pro version: 2.6
// Code is generated on: 2011年7月5日 11:37:43
// Code is generated using templates: SD.TemplateBindings.SharedTemplates.NET20
// Templates vendor: Solutions Design.
// Templates version: 
//////////////////////////////////////////////////////////////
using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Collections;
#if !CF
using System.Runtime.Serialization;
#endif
using System.Data;
using System.Xml.Serialization;
using CARMSData;
using CARMSData.FactoryClasses;
using CARMSData.DaoClasses;
using CARMSData.RelationClasses;
using CARMSData.HelperClasses;
using CARMSData.CollectionClasses;

using SD.LLBLGen.Pro.ORMSupportClasses;

namespace CARMSData.EntityClasses
{
	
	// __LLBLGENPRO_USER_CODE_REGION_START AdditionalNamespaces
	// __LLBLGENPRO_USER_CODE_REGION_END

	/// <summary>
	/// Entity class which represents the entity 'ReportHeader'. <br/><br/>
	/// 
	/// </summary>
	[Serializable]
	public partial class ReportHeaderEntity : CommonEntityBase, ISerializable
		// __LLBLGENPRO_USER_CODE_REGION_START AdditionalInterfaces
		// __LLBLGENPRO_USER_CODE_REGION_END	
	{
		#region Class Member Declarations
		private CARMSData.CollectionClasses.MessageCollection	_message;
		private bool	_alwaysFetchMessage, _alreadyFetchedMessage;
		private CARMSData.CollectionClasses.ReportValueCollection	_reportValue;
		private bool	_alwaysFetchReportValue, _alreadyFetchedReportValue;
		private CARMSData.CollectionClasses.ReportPropertyCollection _reportPropertyCollectionViaReportValue;
		private bool	_alwaysFetchReportPropertyCollectionViaReportValue, _alreadyFetchedReportPropertyCollectionViaReportValue;
		private CARMSData.CollectionClasses.TemplateCollection _templateCollectionViaMessage;
		private bool	_alwaysFetchTemplateCollectionViaMessage, _alreadyFetchedTemplateCollectionViaMessage;
		private CARMSData.CollectionClasses.UserCollection _userCollectionViaMessage;
		private bool	_alwaysFetchUserCollectionViaMessage, _alreadyFetchedUserCollectionViaMessage;
		private ReportCategoryEntity _reportCategory;
		private bool	_alwaysFetchReportCategory, _alreadyFetchedReportCategory, _reportCategoryReturnsNewIfNotFound;
		private ReportFlowEntity _reportFlow;
		private bool	_alwaysFetchReportFlow, _alreadyFetchedReportFlow, _reportFlowReturnsNewIfNotFound;
		private UserEntity _user;
		private bool	_alwaysFetchUser, _alreadyFetchedUser, _userReturnsNewIfNotFound;

		
		// __LLBLGENPRO_USER_CODE_REGION_START PrivateMembers
		// __LLBLGENPRO_USER_CODE_REGION_END
		#endregion

		#region Statics
		private static Dictionary<string, string>	_customProperties;
		private static Dictionary<string, Dictionary<string, string>>	_fieldsCustomProperties;

		/// <summary>All names of fields mapped onto a relation. Usable for in-memory filtering</summary>
		public static partial class MemberNames
		{
			/// <summary>Member name ReportCategory</summary>
			public static readonly string ReportCategory = "ReportCategory";
			/// <summary>Member name ReportFlow</summary>
			public static readonly string ReportFlow = "ReportFlow";
			/// <summary>Member name User</summary>
			public static readonly string User = "User";
			/// <summary>Member name Message</summary>
			public static readonly string Message = "Message";
			/// <summary>Member name ReportValue</summary>
			public static readonly string ReportValue = "ReportValue";
			/// <summary>Member name ReportPropertyCollectionViaReportValue</summary>
			public static readonly string ReportPropertyCollectionViaReportValue = "ReportPropertyCollectionViaReportValue";
			/// <summary>Member name TemplateCollectionViaMessage</summary>
			public static readonly string TemplateCollectionViaMessage = "TemplateCollectionViaMessage";
			/// <summary>Member name UserCollectionViaMessage</summary>
			public static readonly string UserCollectionViaMessage = "UserCollectionViaMessage";

		}
		#endregion
		
		/// <summary>Static CTor for setting up custom property hashtables. Is executed before the first instance of this entity class or derived classes is constructed. </summary>
		static ReportHeaderEntity()
		{
			SetupCustomPropertyHashtables();
		}

		/// <summary>CTor</summary>
		public ReportHeaderEntity()
		{
			InitClassEmpty(null);
		}


		/// <summary>CTor</summary>
		/// <param name="reportHeaderId">PK value for ReportHeader which data should be fetched into this ReportHeader object</param>
		public ReportHeaderEntity(System.Int32 reportHeaderId)
		{
			InitClassFetch(reportHeaderId, null, null);
		}

		/// <summary>CTor</summary>
		/// <param name="reportHeaderId">PK value for ReportHeader which data should be fetched into this ReportHeader object</param>
		/// <param name="prefetchPathToUse">the PrefetchPath which defines the graph of objects to fetch as well</param>
		public ReportHeaderEntity(System.Int32 reportHeaderId, IPrefetchPath prefetchPathToUse)
		{
			InitClassFetch(reportHeaderId, null, prefetchPathToUse);
		}

		/// <summary>CTor</summary>
		/// <param name="reportHeaderId">PK value for ReportHeader which data should be fetched into this ReportHeader object</param>
		/// <param name="validator">The custom validator object for this ReportHeaderEntity</param>
		public ReportHeaderEntity(System.Int32 reportHeaderId, IValidator validator)
		{
			InitClassFetch(reportHeaderId, validator, null);
		}


		/// <summary>Private CTor for deserialization</summary>
		/// <param name="info"></param>
		/// <param name="context"></param>
		protected ReportHeaderEntity(SerializationInfo info, StreamingContext context) : base(info, context)
		{
			_message = (CARMSData.CollectionClasses.MessageCollection)info.GetValue("_message", typeof(CARMSData.CollectionClasses.MessageCollection));
			_alwaysFetchMessage = info.GetBoolean("_alwaysFetchMessage");
			_alreadyFetchedMessage = info.GetBoolean("_alreadyFetchedMessage");
			_reportValue = (CARMSData.CollectionClasses.ReportValueCollection)info.GetValue("_reportValue", typeof(CARMSData.CollectionClasses.ReportValueCollection));
			_alwaysFetchReportValue = info.GetBoolean("_alwaysFetchReportValue");
			_alreadyFetchedReportValue = info.GetBoolean("_alreadyFetchedReportValue");
			_reportPropertyCollectionViaReportValue = (CARMSData.CollectionClasses.ReportPropertyCollection)info.GetValue("_reportPropertyCollectionViaReportValue", typeof(CARMSData.CollectionClasses.ReportPropertyCollection));
			_alwaysFetchReportPropertyCollectionViaReportValue = info.GetBoolean("_alwaysFetchReportPropertyCollectionViaReportValue");
			_alreadyFetchedReportPropertyCollectionViaReportValue = info.GetBoolean("_alreadyFetchedReportPropertyCollectionViaReportValue");
			_templateCollectionViaMessage = (CARMSData.CollectionClasses.TemplateCollection)info.GetValue("_templateCollectionViaMessage", typeof(CARMSData.CollectionClasses.TemplateCollection));
			_alwaysFetchTemplateCollectionViaMessage = info.GetBoolean("_alwaysFetchTemplateCollectionViaMessage");
			_alreadyFetchedTemplateCollectionViaMessage = info.GetBoolean("_alreadyFetchedTemplateCollectionViaMessage");
			_userCollectionViaMessage = (CARMSData.CollectionClasses.UserCollection)info.GetValue("_userCollectionViaMessage", typeof(CARMSData.CollectionClasses.UserCollection));
			_alwaysFetchUserCollectionViaMessage = info.GetBoolean("_alwaysFetchUserCollectionViaMessage");
			_alreadyFetchedUserCollectionViaMessage = info.GetBoolean("_alreadyFetchedUserCollectionViaMessage");
			_reportCategory = (ReportCategoryEntity)info.GetValue("_reportCategory", typeof(ReportCategoryEntity));
			if(_reportCategory!=null)
			{
				_reportCategory.AfterSave+=new EventHandler(OnEntityAfterSave);
			}
			_reportCategoryReturnsNewIfNotFound = info.GetBoolean("_reportCategoryReturnsNewIfNotFound");
			_alwaysFetchReportCategory = info.GetBoolean("_alwaysFetchReportCategory");
			_alreadyFetchedReportCategory = info.GetBoolean("_alreadyFetchedReportCategory");
			_reportFlow = (ReportFlowEntity)info.GetValue("_reportFlow", typeof(ReportFlowEntity));
			if(_reportFlow!=null)
			{
				_reportFlow.AfterSave+=new EventHandler(OnEntityAfterSave);
			}
			_reportFlowReturnsNewIfNotFound = info.GetBoolean("_reportFlowReturnsNewIfNotFound");
			_alwaysFetchReportFlow = info.GetBoolean("_alwaysFetchReportFlow");
			_alreadyFetchedReportFlow = info.GetBoolean("_alreadyFetchedReportFlow");
			_user = (UserEntity)info.GetValue("_user", typeof(UserEntity));
			if(_user!=null)
			{
				_user.AfterSave+=new EventHandler(OnEntityAfterSave);
			}
			_userReturnsNewIfNotFound = info.GetBoolean("_userReturnsNewIfNotFound");
			_alwaysFetchUser = info.GetBoolean("_alwaysFetchUser");
			_alreadyFetchedUser = info.GetBoolean("_alreadyFetchedUser");

			base.FixupDeserialization(FieldInfoProviderSingleton.GetInstance(), PersistenceInfoProviderSingleton.GetInstance());
			
			// __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor
			// __LLBLGENPRO_USER_CODE_REGION_END
		}

		
		/// <summary>Performs the desync setup when an FK field has been changed. The entity referenced based on the FK field will be dereferenced and sync info will be removed.</summary>
		/// <param name="fieldIndex">The fieldindex.</param>
		protected override void PerformDesyncSetupFKFieldChange(int fieldIndex)
		{
			switch((ReportHeaderFieldIndex)fieldIndex)
			{
				case ReportHeaderFieldIndex.ReportCategoryId:
					DesetupSyncReportCategory(true, false);
					_alreadyFetchedReportCategory = false;
					break;
				case ReportHeaderFieldIndex.ApplyUserId:
					DesetupSyncUser(true, false);
					_alreadyFetchedUser = false;
					break;
				case ReportHeaderFieldIndex.ReportFlowId:
					DesetupSyncReportFlow(true, false);
					_alreadyFetchedReportFlow = false;
					break;
				default:
					base.PerformDesyncSetupFKFieldChange(fieldIndex);
					break;
			}
		}
		
		/// <summary>Gets the inheritance info provider instance of the project this entity instance is located in. </summary>
		/// <returns>ready to use inheritance info provider instance.</returns>
		protected override IInheritanceInfoProvider GetInheritanceInfoProvider()
		{
			return InheritanceInfoProviderSingleton.GetInstance();
		}
		
		/// <summary> Will perform post-ReadXml actions</summary>
		protected override void PostReadXmlFixups()
		{
			_alreadyFetchedMessage = (_message.Count > 0);
			_alreadyFetchedReportValue = (_reportValue.Count > 0);
			_alreadyFetchedReportPropertyCollectionViaReportValue = (_reportPropertyCollectionViaReportValue.Count > 0);
			_alreadyFetchedTemplateCollectionViaMessage = (_templateCollectionViaMessage.Count > 0);
			_alreadyFetchedUserCollectionViaMessage = (_userCollectionViaMessage.Count > 0);
			_alreadyFetchedReportCategory = (_reportCategory != null);
			_alreadyFetchedReportFlow = (_reportFlow != null);
			_alreadyFetchedUser = (_user != null);

		}
				
		/// <summary>Gets the relation objects which represent the relation the fieldName specified is mapped on. </summary>
		/// <param name="fieldName">Name of the field mapped onto the relation of which the relation objects have to be obtained.</param>
		/// <returns>RelationCollection with relation object(s) which represent the relation the field is maped on</returns>
		public override RelationCollection GetRelationsForFieldOfType(string fieldName)
		{
			return ReportHeaderEntity.GetRelationsForField(fieldName);
		}

		/// <summary>Gets the relation objects which represent the relation the fieldName specified is mapped on. </summary>
		/// <param name="fieldName">Name of the field mapped onto the relation of which the relation objects have to be obtained.</param>
		/// <returns>RelationCollection with relation object(s) which represent the relation the field is maped on</returns>
		public static RelationCollection GetRelationsForField(string fieldName)
		{
			RelationCollection toReturn = new RelationCollection();
			switch(fieldName)
			{
				case "ReportCategory":
					toReturn.Add(ReportHeaderEntity.Relations.ReportCategoryEntityUsingReportCategoryId);
					break;
				case "ReportFlow":
					toReturn.Add(ReportHeaderEntity.Relations.ReportFlowEntityUsingReportFlowId);
					break;
				case "User":
					toReturn.Add(ReportHeaderEntity.Relations.UserEntityUsingApplyUserId);
					break;
				case "Message":
					toReturn.Add(ReportHeaderEntity.Relations.MessageEntityUsingReportHeaderId);
					break;
				case "ReportValue":
					toReturn.Add(ReportHeaderEntity.Relations.ReportValueEntityUsingReportHeaderId);
					break;
				case "ReportPropertyCollectionViaReportValue":
					toReturn.Add(ReportHeaderEntity.Relations.ReportValueEntityUsingReportHeaderId, "ReportHeaderEntity__", "ReportValue_", JoinHint.None);
					toReturn.Add(ReportValueEntity.Relations.ReportPropertyEntityUsingPropertyId, "ReportValue_", string.Empty, JoinHint.None);
					break;
				case "TemplateCollectionViaMessage":
					toReturn.Add(ReportHeaderEntity.Relations.MessageEntityUsingReportHeaderId, "ReportHeaderEntity__", "Message_", JoinHint.None);
					toReturn.Add(MessageEntity.Relations.TemplateEntityUsingTemplateId, "Message_", string.Empty, JoinHint.None);
					break;
				case "UserCollectionViaMessage":
					toReturn.Add(ReportHeaderEntity.Relations.MessageEntityUsingReportHeaderId, "ReportHeaderEntity__", "Message_", JoinHint.None);
					toReturn.Add(MessageEntity.Relations.UserEntityUsingTargetUserId, "Message_", string.Empty, JoinHint.None);
					break;

				default:

					break;				
			}
			return toReturn;
		}



		/// <summary> ISerializable member. Does custom serialization so event handlers do not get serialized.
		/// Serializes members of this entity class and uses the base class' implementation to serialize the rest.</summary>
		/// <param name="info"></param>
		/// <param name="context"></param>
		[EditorBrowsable(EditorBrowsableState.Never)]
		public override void GetObjectData(SerializationInfo info, StreamingContext context)
		{
			info.AddValue("_message", (!this.MarkedForDeletion?_message:null));
			info.AddValue("_alwaysFetchMessage", _alwaysFetchMessage);
			info.AddValue("_alreadyFetchedMessage", _alreadyFetchedMessage);
			info.AddValue("_reportValue", (!this.MarkedForDeletion?_reportValue:null));
			info.AddValue("_alwaysFetchReportValue", _alwaysFetchReportValue);
			info.AddValue("_alreadyFetchedReportValue", _alreadyFetchedReportValue);
			info.AddValue("_reportPropertyCollectionViaReportValue", (!this.MarkedForDeletion?_reportPropertyCollectionViaReportValue:null));
			info.AddValue("_alwaysFetchReportPropertyCollectionViaReportValue", _alwaysFetchReportPropertyCollectionViaReportValue);
			info.AddValue("_alreadyFetchedReportPropertyCollectionViaReportValue", _alreadyFetchedReportPropertyCollectionViaReportValue);
			info.AddValue("_templateCollectionViaMessage", (!this.MarkedForDeletion?_templateCollectionViaMessage:null));
			info.AddValue("_alwaysFetchTemplateCollectionViaMessage", _alwaysFetchTemplateCollectionViaMessage);
			info.AddValue("_alreadyFetchedTemplateCollectionViaMessage", _alreadyFetchedTemplateCollectionViaMessage);
			info.AddValue("_userCollectionViaMessage", (!this.MarkedForDeletion?_userCollectionViaMessage:null));
			info.AddValue("_alwaysFetchUserCollectionViaMessage", _alwaysFetchUserCollectionViaMessage);
			info.AddValue("_alreadyFetchedUserCollectionViaMessage", _alreadyFetchedUserCollectionViaMessage);
			info.AddValue("_reportCategory", (!this.MarkedForDeletion?_reportCategory:null));
			info.AddValue("_reportCategoryReturnsNewIfNotFound", _reportCategoryReturnsNewIfNotFound);
			info.AddValue("_alwaysFetchReportCategory", _alwaysFetchReportCategory);
			info.AddValue("_alreadyFetchedReportCategory", _alreadyFetchedReportCategory);
			info.AddValue("_reportFlow", (!this.MarkedForDeletion?_reportFlow:null));
			info.AddValue("_reportFlowReturnsNewIfNotFound", _reportFlowReturnsNewIfNotFound);
			info.AddValue("_alwaysFetchReportFlow", _alwaysFetchReportFlow);
			info.AddValue("_alreadyFetchedReportFlow", _alreadyFetchedReportFlow);
			info.AddValue("_user", (!this.MarkedForDeletion?_user:null));
			info.AddValue("_userReturnsNewIfNotFound", _userReturnsNewIfNotFound);
			info.AddValue("_alwaysFetchUser", _alwaysFetchUser);
			info.AddValue("_alreadyFetchedUser", _alreadyFetchedUser);

			
			// __LLBLGENPRO_USER_CODE_REGION_START GetObjectInfo
			// __LLBLGENPRO_USER_CODE_REGION_END
			base.GetObjectData(info, context);
		}
		
		/// <summary> Sets the related entity property to the entity specified. If the property is a collection, it will add the entity specified to that collection.</summary>
		/// <param name="propertyName">Name of the property.</param>
		/// <param name="entity">Entity to set as an related entity</param>
		/// <remarks>Used by prefetch path logic.</remarks>
		[EditorBrowsable(EditorBrowsableState.Never)]
		public override void SetRelatedEntityProperty(string propertyName, IEntity entity)
		{
			switch(propertyName)
			{
				case "ReportCategory":
					_alreadyFetchedReportCategory = true;
					this.ReportCategory = (ReportCategoryEntity)entity;
					break;
				case "ReportFlow":
					_alreadyFetchedReportFlow = true;
					this.ReportFlow = (ReportFlowEntity)entity;
					break;
				case "User":
					_alreadyFetchedUser = true;
					this.User = (UserEntity)entity;
					break;
				case "Message":
					_alreadyFetchedMessage = true;
					if(entity!=null)
					{
						this.Message.Add((MessageEntity)entity);
					}
					break;
				case "ReportValue":
					_alreadyFetchedReportValue = true;
					if(entity!=null)
					{
						this.ReportValue.Add((ReportValueEntity)entity);
					}
					break;
				case "ReportPropertyCollectionViaReportValue":
					_alreadyFetchedReportPropertyCollectionViaReportValue = true;
					if(entity!=null)
					{
						this.ReportPropertyCollectionViaReportValue.Add((ReportPropertyEntity)entity);
					}
					break;
				case "TemplateCollectionViaMessage":
					_alreadyFetchedTemplateCollectionViaMessage = true;
					if(entity!=null)
					{
						this.TemplateCollectionViaMessage.Add((TemplateEntity)entity);
					}
					break;
				case "UserCollectionViaMessage":
					_alreadyFetchedUserCollectionViaMessage = true;
					if(entity!=null)
					{
						this.UserCollectionViaMessage.Add((UserEntity)entity);
					}
					break;

				default:

					break;
			}
		}

		/// <summary> Sets the internal parameter related to the fieldname passed to the instance relatedEntity. </summary>
		/// <param name="relatedEntity">Instance to set as the related entity of type entityType</param>
		/// <param name="fieldName">Name of field mapped onto the relation which resolves in the instance relatedEntity</param>
		[EditorBrowsable(EditorBrowsableState.Never)]
		public override void SetRelatedEntity(IEntity relatedEntity, string fieldName)
		{
			switch(fieldName)
			{
				case "ReportCategory":
					SetupSyncReportCategory(relatedEntity);
					break;
				case "ReportFlow":
					SetupSyncReportFlow(relatedEntity);
					break;
				case "User":
					SetupSyncUser(relatedEntity);
					break;
				case "Message":
					_message.Add((MessageEntity)relatedEntity);
					break;
				case "ReportValue":
					_reportValue.Add((ReportValueEntity)relatedEntity);
					break;

				default:

					break;
			}
		}
		
		/// <summary> Unsets the internal parameter related to the fieldname passed to the instance relatedEntity. Reverses the actions taken by SetRelatedEntity() </summary>
		/// <param name="relatedEntity">Instance to unset as the related entity of type entityType</param>
		/// <param name="fieldName">Name of field mapped onto the relation which resolves in the instance relatedEntity</param>
		/// <param name="signalRelatedEntityManyToOne">if set to true it will notify the manytoone side, if applicable.</param>
		[EditorBrowsable(EditorBrowsableState.Never)]
		public override void UnsetRelatedEntity(IEntity relatedEntity, string fieldName, bool signalRelatedEntityManyToOne)
		{
			switch(fieldName)
			{
				case "ReportCategory":
					DesetupSyncReportCategory(false, true);
					break;
				case "ReportFlow":
					DesetupSyncReportFlow(false, true);
					break;
				case "User":
					DesetupSyncUser(false, true);
					break;
				case "Message":
					base.PerformRelatedEntityRemoval(_message, relatedEntity, signalRelatedEntityManyToOne);
					break;
				case "ReportValue":
					base.PerformRelatedEntityRemoval(_reportValue, relatedEntity, signalRelatedEntityManyToOne);
					break;

				default:

					break;
			}
		}

		/// <summary> Gets a collection of related entities referenced by this entity which depend on this entity (this entity is the PK side of their FK fields). These
		/// entities will have to be persisted after this entity during a recursive save.</summary>
		/// <returns>Collection with 0 or more IEntity objects, referenced by this entity</returns>
		public override List<IEntity> GetDependingRelatedEntities()
		{
			List<IEntity> toReturn = new List<IEntity>();


			return toReturn;
		}
		
		/// <summary> Gets a collection of related entities referenced by this entity which this entity depends on (this entity is the FK side of their PK fields). These
		/// entities will have to be persisted before this entity during a recursive save.</summary>
		/// <returns>Collection with 0 or more IEntity objects, referenced by this entity</returns>
		public override List<IEntity> GetDependentRelatedEntities()
		{
			List<IEntity> toReturn = new List<IEntity>();
			if(_reportCategory!=null)
			{
				toReturn.Add(_reportCategory);
			}
			if(_reportFlow!=null)
			{
				toReturn.Add(_reportFlow);
			}
			if(_user!=null)
			{
				toReturn.Add(_user);
			}


			return toReturn;
		}
		
		/// <summary> Gets a List of all entity collections stored as member variables in this entity. The contents of the ArrayList is
		/// used by the DataAccessAdapter to perform recursive saves. Only 1:n related collections are returned.</summary>
		/// <returns>Collection with 0 or more IEntityCollection objects, referenced by this entity</returns>
		public override List<IEntityCollection> GetMemberEntityCollections()
		{
			List<IEntityCollection> toReturn = new List<IEntityCollection>();
			toReturn.Add(_message);
			toReturn.Add(_reportValue);

			return toReturn;
		}

		

		

		/// <summary> Fetches the contents of this entity from the persistent storage using the primary key.</summary>
		/// <param name="reportHeaderId">PK value for ReportHeader which data should be fetched into this ReportHeader object</param>
		/// <returns>True if succeeded, false otherwise.</returns>
		public bool FetchUsingPK(System.Int32 reportHeaderId)
		{
			return FetchUsingPK(reportHeaderId, null, null, null);
		}

		/// <summary> Fetches the contents of this entity from the persistent storage using the primary key.</summary>
		/// <param name="reportHeaderId">PK value for ReportHeader which data should be fetched into this ReportHeader object</param>
		/// <param name="prefetchPathToUse">the PrefetchPath which defines the graph of objects to fetch as well</param>
		/// <returns>True if succeeded, false otherwise.</returns>
		public bool FetchUsingPK(System.Int32 reportHeaderId, IPrefetchPath prefetchPathToUse)
		{
			return FetchUsingPK(reportHeaderId, prefetchPathToUse, null, null);
		}

		/// <summary> Fetches the contents of this entity from the persistent storage using the primary key.</summary>
		/// <param name="reportHeaderId">PK value for ReportHeader which data should be fetched into this ReportHeader object</param>
		/// <param name="prefetchPathToUse">the PrefetchPath which defines the graph of objects to fetch as well</param>
		/// <param name="contextToUse">The context to add the entity to if the fetch was succesful. </param>
		/// <returns>True if succeeded, false otherwise.</returns>
		public bool FetchUsingPK(System.Int32 reportHeaderId, IPrefetchPath prefetchPathToUse, Context contextToUse)
		{
			return Fetch(reportHeaderId, prefetchPathToUse, contextToUse, null);
		}

		/// <summary> Fetches the contents of this entity from the persistent storage using the primary key.</summary>
		/// <param name="reportHeaderId">PK value for ReportHeader which data should be fetched into this ReportHeader object</param>
		/// <param name="prefetchPathToUse">the PrefetchPath which defines the graph of objects to fetch as well</param>
		/// <param name="contextToUse">The context to add the entity to if the fetch was succesful. </param>
		/// <param name="excludedIncludedFields">The list of IEntityField objects which have to be excluded or included for the fetch. 
		/// If null or empty, all fields are fetched (default). If an instance of ExcludeIncludeFieldsList is passed in and its ExcludeContainedFields property
		/// is set to false, the fields contained in excludedIncludedFields are kept in the query, the rest of the fields in the query are excluded.</param>
		/// <returns>True if succeeded, false otherwise.</returns>
		public bool FetchUsingPK(System.Int32 reportHeaderId, IPrefetchPath prefetchPathToUse, Context contextToUse, ExcludeIncludeFieldsList excludedIncludedFields)
		{
			return Fetch(reportHeaderId, prefetchPathToUse, contextToUse, excludedIncludedFields);
		}

		/// <summary> Refetches the Entity from the persistent storage. Refetch is used to re-load an Entity which is marked "Out-of-sync", due to a save action. 
		/// Refetching an empty Entity has no effect. </summary>
		/// <returns>true if Refetch succeeded, false otherwise</returns>
		public override bool Refetch()
		{
			return Fetch(this.ReportHeaderId, null, null, null);
		}

		/// <summary> Returns true if the original value for the field with the fieldIndex passed in, read from the persistent storage was NULL, false otherwise.
		/// Should not be used for testing if the current value is NULL, use <see cref="TestCurrentFieldValueForNull"/> for that.</summary>
		/// <param name="fieldIndex">Index of the field to test if that field was NULL in the persistent storage</param>
		/// <returns>true if the field with the passed in index was NULL in the persistent storage, false otherwise</returns>
		public bool TestOriginalFieldValueForNull(ReportHeaderFieldIndex fieldIndex)
		{
			return base.Fields[(int)fieldIndex].IsNull;
		}
		
		/// <summary>Returns true if the current value for the field with the fieldIndex passed in represents null/not defined, false otherwise.
		/// Should not be used for testing if the original value (read from the db) is NULL</summary>
		/// <param name="fieldIndex">Index of the field to test if its currentvalue is null/undefined</param>
		/// <returns>true if the field's value isn't defined yet, false otherwise</returns>
		public bool TestCurrentFieldValueForNull(ReportHeaderFieldIndex fieldIndex)
		{
			return base.CheckIfCurrentFieldValueIsNull((int)fieldIndex);
		}

				
		/// <summary>Gets a list of all the EntityRelation objects the type of this instance has.</summary>
		/// <returns>A list of all the EntityRelation objects the type of this instance has. Hierarchy relations are excluded.</returns>
		public override List<IEntityRelation> GetAllRelations()
		{
			return new ReportHeaderRelations().GetAllRelations();
		}


		/// <summary> Retrieves all related entities of type 'MessageEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <returns>Filled collection with all related entities of type 'MessageEntity'</returns>
		public CARMSData.CollectionClasses.MessageCollection GetMultiMessage(bool forceFetch)
		{
			return GetMultiMessage(forceFetch, _message.EntityFactoryToUse, null);
		}

		/// <summary> Retrieves all related entities of type 'MessageEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="filter">Extra filter to limit the resultset.</param>
		/// <returns>Filled collection with all related entities of type 'MessageEntity'</returns>
		public CARMSData.CollectionClasses.MessageCollection GetMultiMessage(bool forceFetch, IPredicateExpression filter)
		{
			return GetMultiMessage(forceFetch, _message.EntityFactoryToUse, filter);
		}

		/// <summary> Retrieves all related entities of type 'MessageEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToOne() routine.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public CARMSData.CollectionClasses.MessageCollection GetMultiMessage(bool forceFetch, IEntityFactory entityFactoryToUse)
		{
			return GetMultiMessage(forceFetch, entityFactoryToUse, null);
		}

		/// <summary> Retrieves all related entities of type 'MessageEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToOne() routine.</param>
		/// <param name="filter">Extra filter to limit the resultset.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public virtual CARMSData.CollectionClasses.MessageCollection GetMultiMessage(bool forceFetch, IEntityFactory entityFactoryToUse, IPredicateExpression filter)
		{
 			if( ( !_alreadyFetchedMessage || forceFetch || _alwaysFetchMessage) && !base.IsSerializing && !base.IsDeserializing && !base.InDesignMode)
			{
				if(base.ParticipatesInTransaction)
				{
					if(!_message.ParticipatesInTransaction)
					{
						base.Transaction.Add(_message);
					}
				}
				_message.SuppressClearInGetMulti=!forceFetch;
				if(entityFactoryToUse!=null)
				{
					_message.EntityFactoryToUse = entityFactoryToUse;
				}
				_message.GetMultiManyToOne(this, null, null, filter);
				_message.SuppressClearInGetMulti=false;
				_alreadyFetchedMessage = true;
			}
			return _message;
		}

		/// <summary> Sets the collection parameters for the collection for 'Message'. These settings will be taken into account
		/// when the property Message is requested or GetMultiMessage is called.</summary>
		/// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return. When set to 0, this parameter is ignored</param>
		/// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified (null), no sorting is applied.</param>
		public virtual void SetCollectionParametersMessage(long maxNumberOfItemsToReturn, ISortExpression sortClauses)
		{
			_message.SortClauses=sortClauses;
			_message.MaxNumberOfItemsToReturn=maxNumberOfItemsToReturn;
		}

		/// <summary> Retrieves all related entities of type 'ReportValueEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <returns>Filled collection with all related entities of type 'ReportValueEntity'</returns>
		public CARMSData.CollectionClasses.ReportValueCollection GetMultiReportValue(bool forceFetch)
		{
			return GetMultiReportValue(forceFetch, _reportValue.EntityFactoryToUse, null);
		}

		/// <summary> Retrieves all related entities of type 'ReportValueEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="filter">Extra filter to limit the resultset.</param>
		/// <returns>Filled collection with all related entities of type 'ReportValueEntity'</returns>
		public CARMSData.CollectionClasses.ReportValueCollection GetMultiReportValue(bool forceFetch, IPredicateExpression filter)
		{
			return GetMultiReportValue(forceFetch, _reportValue.EntityFactoryToUse, filter);
		}

		/// <summary> Retrieves all related entities of type 'ReportValueEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToOne() routine.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public CARMSData.CollectionClasses.ReportValueCollection GetMultiReportValue(bool forceFetch, IEntityFactory entityFactoryToUse)
		{
			return GetMultiReportValue(forceFetch, entityFactoryToUse, null);
		}

		/// <summary> Retrieves all related entities of type 'ReportValueEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToOne() routine.</param>
		/// <param name="filter">Extra filter to limit the resultset.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public virtual CARMSData.CollectionClasses.ReportValueCollection GetMultiReportValue(bool forceFetch, IEntityFactory entityFactoryToUse, IPredicateExpression filter)
		{
 			if( ( !_alreadyFetchedReportValue || forceFetch || _alwaysFetchReportValue) && !base.IsSerializing && !base.IsDeserializing && !base.InDesignMode)
			{
				if(base.ParticipatesInTransaction)
				{
					if(!_reportValue.ParticipatesInTransaction)
					{
						base.Transaction.Add(_reportValue);
					}
				}
				_reportValue.SuppressClearInGetMulti=!forceFetch;
				if(entityFactoryToUse!=null)
				{
					_reportValue.EntityFactoryToUse = entityFactoryToUse;
				}
				_reportValue.GetMultiManyToOne(this, null, filter);
				_reportValue.SuppressClearInGetMulti=false;
				_alreadyFetchedReportValue = true;
			}
			return _reportValue;
		}

		/// <summary> Sets the collection parameters for the collection for 'ReportValue'. These settings will be taken into account
		/// when the property ReportValue is requested or GetMultiReportValue is called.</summary>
		/// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return. When set to 0, this parameter is ignored</param>
		/// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified (null), no sorting is applied.</param>
		public virtual void SetCollectionParametersReportValue(long maxNumberOfItemsToReturn, ISortExpression sortClauses)
		{
			_reportValue.SortClauses=sortClauses;
			_reportValue.MaxNumberOfItemsToReturn=maxNumberOfItemsToReturn;
		}

		/// <summary> Retrieves all related entities of type 'ReportPropertyEntity' using a relation of type 'm:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <returns>Filled collection with all related entities of type 'ReportPropertyEntity'</returns>
		public CARMSData.CollectionClasses.ReportPropertyCollection GetMultiReportPropertyCollectionViaReportValue(bool forceFetch)
		{
			return GetMultiReportPropertyCollectionViaReportValue(forceFetch, _reportPropertyCollectionViaReportValue.EntityFactoryToUse);
		}

		/// <summary> Retrieves all related entities of type 'ReportPropertyEntity' using a relation of type 'm:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToMany() routine.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public CARMSData.CollectionClasses.ReportPropertyCollection GetMultiReportPropertyCollectionViaReportValue(bool forceFetch, IEntityFactory entityFactoryToUse)
		{
 			if( ( !_alreadyFetchedReportPropertyCollectionViaReportValue || forceFetch || _alwaysFetchReportPropertyCollectionViaReportValue) && !base.IsSerializing && !base.IsDeserializing && !base.InDesignMode)
			{
				if(base.ParticipatesInTransaction)
				{
					if(!_reportPropertyCollectionViaReportValue.ParticipatesInTransaction)
					{
						base.Transaction.Add(_reportPropertyCollectionViaReportValue);
					}
				}
				IPredicateExpression filter = new PredicateExpression();
				filter.Add(new FieldCompareValuePredicate(ReportHeaderFields.ReportHeaderId, ComparisonOperator.Equal, this.ReportHeaderId, "ReportHeaderEntity__"));
				_reportPropertyCollectionViaReportValue.SuppressClearInGetMulti=!forceFetch;
				if(entityFactoryToUse!=null)
				{
					_reportPropertyCollectionViaReportValue.EntityFactoryToUse = entityFactoryToUse;
				}
				_reportPropertyCollectionViaReportValue.GetMulti(filter, GetRelationsForField("ReportPropertyCollectionViaReportValue"));
				_reportPropertyCollectionViaReportValue.SuppressClearInGetMulti=false;
				_alreadyFetchedReportPropertyCollectionViaReportValue = true;
			}
			return _reportPropertyCollectionViaReportValue;
		}

		/// <summary> Sets the collection parameters for the collection for 'ReportPropertyCollectionViaReportValue'. These settings will be taken into account
		/// when the property ReportPropertyCollectionViaReportValue is requested or GetMultiReportPropertyCollectionViaReportValue is called.</summary>
		/// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return. When set to 0, this parameter is ignored</param>
		/// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified (null), no sorting is applied.</param>
		public virtual void SetCollectionParametersReportPropertyCollectionViaReportValue(long maxNumberOfItemsToReturn, ISortExpression sortClauses)
		{
			_reportPropertyCollectionViaReportValue.SortClauses=sortClauses;
			_reportPropertyCollectionViaReportValue.MaxNumberOfItemsToReturn=maxNumberOfItemsToReturn;
		}

		/// <summary> Retrieves all related entities of type 'TemplateEntity' using a relation of type 'm:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <returns>Filled collection with all related entities of type 'TemplateEntity'</returns>
		public CARMSData.CollectionClasses.TemplateCollection GetMultiTemplateCollectionViaMessage(bool forceFetch)
		{
			return GetMultiTemplateCollectionViaMessage(forceFetch, _templateCollectionViaMessage.EntityFactoryToUse);
		}

		/// <summary> Retrieves all related entities of type 'TemplateEntity' using a relation of type 'm:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToMany() routine.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public CARMSData.CollectionClasses.TemplateCollection GetMultiTemplateCollectionViaMessage(bool forceFetch, IEntityFactory entityFactoryToUse)
		{
 			if( ( !_alreadyFetchedTemplateCollectionViaMessage || forceFetch || _alwaysFetchTemplateCollectionViaMessage) && !base.IsSerializing && !base.IsDeserializing && !base.InDesignMode)
			{
				if(base.ParticipatesInTransaction)
				{
					if(!_templateCollectionViaMessage.ParticipatesInTransaction)
					{
						base.Transaction.Add(_templateCollectionViaMessage);
					}
				}
				IPredicateExpression filter = new PredicateExpression();
				filter.Add(new FieldCompareValuePredicate(ReportHeaderFields.ReportHeaderId, ComparisonOperator.Equal, this.ReportHeaderId, "ReportHeaderEntity__"));
				_templateCollectionViaMessage.SuppressClearInGetMulti=!forceFetch;
				if(entityFactoryToUse!=null)
				{
					_templateCollectionViaMessage.EntityFactoryToUse = entityFactoryToUse;
				}
				_templateCollectionViaMessage.GetMulti(filter, GetRelationsForField("TemplateCollectionViaMessage"));
				_templateCollectionViaMessage.SuppressClearInGetMulti=false;
				_alreadyFetchedTemplateCollectionViaMessage = true;
			}
			return _templateCollectionViaMessage;
		}

		/// <summary> Sets the collection parameters for the collection for 'TemplateCollectionViaMessage'. These settings will be taken into account
		/// when the property TemplateCollectionViaMessage is requested or GetMultiTemplateCollectionViaMessage is called.</summary>
		/// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return. When set to 0, this parameter is ignored</param>
		/// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified (null), no sorting is applied.</param>
		public virtual void SetCollectionParametersTemplateCollectionViaMessage(long maxNumberOfItemsToReturn, ISortExpression sortClauses)
		{
			_templateCollectionViaMessage.SortClauses=sortClauses;
			_templateCollectionViaMessage.MaxNumberOfItemsToReturn=maxNumberOfItemsToReturn;
		}

		/// <summary> Retrieves all related entities of type 'UserEntity' using a relation of type 'm:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <returns>Filled collection with all related entities of type 'UserEntity'</returns>
		public CARMSData.CollectionClasses.UserCollection GetMultiUserCollectionViaMessage(bool forceFetch)
		{
			return GetMultiUserCollectionViaMessage(forceFetch, _userCollectionViaMessage.EntityFactoryToUse);
		}

		/// <summary> Retrieves all related entities of type 'UserEntity' using a relation of type 'm:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToMany() routine.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public CARMSData.CollectionClasses.UserCollection GetMultiUserCollectionViaMessage(bool forceFetch, IEntityFactory entityFactoryToUse)
		{
 			if( ( !_alreadyFetchedUserCollectionViaMessage || forceFetch || _alwaysFetchUserCollectionViaMessage) && !base.IsSerializing && !base.IsDeserializing && !base.InDesignMode)
			{
				if(base.ParticipatesInTransaction)
				{
					if(!_userCollectionViaMessage.ParticipatesInTransaction)
					{
						base.Transaction.Add(_userCollectionViaMessage);
					}
				}
				IPredicateExpression filter = new PredicateExpression();
				filter.Add(new FieldCompareValuePredicate(ReportHeaderFields.ReportHeaderId, ComparisonOperator.Equal, this.ReportHeaderId, "ReportHeaderEntity__"));
				_userCollectionViaMessage.SuppressClearInGetMulti=!forceFetch;
				if(entityFactoryToUse!=null)
				{
					_userCollectionViaMessage.EntityFactoryToUse = entityFactoryToUse;
				}
				_userCollectionViaMessage.GetMulti(filter, GetRelationsForField("UserCollectionViaMessage"));
				_userCollectionViaMessage.SuppressClearInGetMulti=false;
				_alreadyFetchedUserCollectionViaMessage = true;
			}
			return _userCollectionViaMessage;
		}

		/// <summary> Sets the collection parameters for the collection for 'UserCollectionViaMessage'. These settings will be taken into account
		/// when the property UserCollectionViaMessage is requested or GetMultiUserCollectionViaMessage is called.</summary>
		/// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return. When set to 0, this parameter is ignored</param>
		/// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified (null), no sorting is applied.</param>
		public virtual void SetCollectionParametersUserCollectionViaMessage(long maxNumberOfItemsToReturn, ISortExpression sortClauses)
		{
			_userCollectionViaMessage.SortClauses=sortClauses;
			_userCollectionViaMessage.MaxNumberOfItemsToReturn=maxNumberOfItemsToReturn;
		}

		/// <summary> Retrieves the related entity of type 'ReportCategoryEntity', using a relation of type 'n:1'</summary>
		/// <returns>A fetched entity of type 'ReportCategoryEntity' which is related to this entity.</returns>
		public ReportCategoryEntity GetSingleReportCategory()
		{
			return GetSingleReportCategory(false);
		}

		/// <summary> Retrieves the related entity of type 'ReportCategoryEntity', using a relation of type 'n:1'</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the currently loaded related entity and will refetch the entity from the persistent storage</param>
		/// <returns>A fetched entity of type 'ReportCategoryEntity' which is related to this entity.</returns>
		public virtual ReportCategoryEntity GetSingleReportCategory(bool forceFetch)
		{
			if( ( !_alreadyFetchedReportCategory || forceFetch || _alwaysFetchReportCategory) && !base.IsSerializing && !base.IsDeserializing  && !base.InDesignMode)			
			{
				bool performLazyLoading = base.CheckIfLazyLoadingShouldOccur(ReportHeaderEntity.Relations.ReportCategoryEntityUsingReportCategoryId);

				ReportCategoryEntity newEntity = new ReportCategoryEntity();
				if(base.ParticipatesInTransaction)
				{
					base.Transaction.Add(newEntity);
				}
				bool fetchResult = false;
				if(performLazyLoading)
				{
					fetchResult = newEntity.FetchUsingPK(this.ReportCategoryId);
				}
				if(fetchResult)
				{
					if(base.ActiveContext!=null)
					{
						newEntity = (ReportCategoryEntity)base.ActiveContext.Get(newEntity);
					}
					this.ReportCategory = newEntity;
				}
				else
				{
					if(_reportCategoryReturnsNewIfNotFound)
					{
						if(performLazyLoading || (!performLazyLoading && (_reportCategory == null)))
						{
							this.ReportCategory = newEntity;
						}
					}
					else
					{
						this.ReportCategory = null;
					}
				}
				_alreadyFetchedReportCategory = fetchResult;
				if(base.ParticipatesInTransaction && !fetchResult)
				{
					base.Transaction.Remove(newEntity);
				}
			}
			return _reportCategory;
		}

		/// <summary> Retrieves the related entity of type 'ReportFlowEntity', using a relation of type 'n:1'</summary>
		/// <returns>A fetched entity of type 'ReportFlowEntity' which is related to this entity.</returns>
		public ReportFlowEntity GetSingleReportFlow()
		{
			return GetSingleReportFlow(false);
		}

		/// <summary> Retrieves the related entity of type 'ReportFlowEntity', using a relation of type 'n:1'</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the currently loaded related entity and will refetch the entity from the persistent storage</param>
		/// <returns>A fetched entity of type 'ReportFlowEntity' which is related to this entity.</returns>
		public virtual ReportFlowEntity GetSingleReportFlow(bool forceFetch)
		{
			if( ( !_alreadyFetchedReportFlow || forceFetch || _alwaysFetchReportFlow) && !base.IsSerializing && !base.IsDeserializing  && !base.InDesignMode)			
			{
				bool performLazyLoading = base.CheckIfLazyLoadingShouldOccur(ReportHeaderEntity.Relations.ReportFlowEntityUsingReportFlowId);

				ReportFlowEntity newEntity = new ReportFlowEntity();
				if(base.ParticipatesInTransaction)
				{
					base.Transaction.Add(newEntity);
				}
				bool fetchResult = false;
				if(performLazyLoading)
				{
					fetchResult = newEntity.FetchUsingPK(this.ReportFlowId.GetValueOrDefault());
				}
				if(fetchResult)
				{
					if(base.ActiveContext!=null)
					{
						newEntity = (ReportFlowEntity)base.ActiveContext.Get(newEntity);
					}
					this.ReportFlow = newEntity;
				}
				else
				{
					if(_reportFlowReturnsNewIfNotFound)
					{
						if(performLazyLoading || (!performLazyLoading && (_reportFlow == null)))
						{
							this.ReportFlow = newEntity;
						}
					}
					else
					{
						this.ReportFlow = null;
					}
				}
				_alreadyFetchedReportFlow = fetchResult;
				if(base.ParticipatesInTransaction && !fetchResult)
				{
					base.Transaction.Remove(newEntity);
				}
			}
			return _reportFlow;
		}

		/// <summary> Retrieves the related entity of type 'UserEntity', using a relation of type 'n:1'</summary>
		/// <returns>A fetched entity of type 'UserEntity' which is related to this entity.</returns>
		public UserEntity GetSingleUser()
		{
			return GetSingleUser(false);
		}

		/// <summary> Retrieves the related entity of type 'UserEntity', using a relation of type 'n:1'</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the currently loaded related entity and will refetch the entity from the persistent storage</param>
		/// <returns>A fetched entity of type 'UserEntity' which is related to this entity.</returns>
		public virtual UserEntity GetSingleUser(bool forceFetch)
		{
			if( ( !_alreadyFetchedUser || forceFetch || _alwaysFetchUser) && !base.IsSerializing && !base.IsDeserializing  && !base.InDesignMode)			
			{
				bool performLazyLoading = base.CheckIfLazyLoadingShouldOccur(ReportHeaderEntity.Relations.UserEntityUsingApplyUserId);

				UserEntity newEntity = new UserEntity();
				if(base.ParticipatesInTransaction)
				{
					base.Transaction.Add(newEntity);
				}
				bool fetchResult = false;
				if(performLazyLoading)
				{
					fetchResult = newEntity.FetchUsingPK(this.ApplyUserId);
				}
				if(fetchResult)
				{
					if(base.ActiveContext!=null)
					{
						newEntity = (UserEntity)base.ActiveContext.Get(newEntity);
					}
					this.User = newEntity;
				}
				else
				{
					if(_userReturnsNewIfNotFound)
					{
						if(performLazyLoading || (!performLazyLoading && (_user == null)))
						{
							this.User = newEntity;
						}
					}
					else
					{
						this.User = null;
					}
				}
				_alreadyFetchedUser = fetchResult;
				if(base.ParticipatesInTransaction && !fetchResult)
				{
					base.Transaction.Remove(newEntity);
				}
			}
			return _user;
		}


		/// <summary> Performs the insert action of a new Entity to the persistent storage.</summary>
		/// <returns>true if succeeded, false otherwise</returns>
		protected override bool InsertEntity()
		{
			ReportHeaderDAO dao = (ReportHeaderDAO)CreateDAOInstance();
			return dao.AddNew(base.Fields, base.Transaction);
		}
		
		/// <summary> Adds the internals to the active context. </summary>
		protected override void AddInternalsToContext()
		{
			_message.ActiveContext = base.ActiveContext;
			_reportValue.ActiveContext = base.ActiveContext;
			_reportPropertyCollectionViaReportValue.ActiveContext = base.ActiveContext;
			_templateCollectionViaMessage.ActiveContext = base.ActiveContext;
			_userCollectionViaMessage.ActiveContext = base.ActiveContext;
			if(_reportCategory!=null)
			{
				_reportCategory.ActiveContext = base.ActiveContext;
			}
			if(_reportFlow!=null)
			{
				_reportFlow.ActiveContext = base.ActiveContext;
			}
			if(_user!=null)
			{
				_user.ActiveContext = base.ActiveContext;
			}


		}


		/// <summary> Performs the update action of an existing Entity to the persistent storage.</summary>
		/// <returns>true if succeeded, false otherwise</returns>
		protected override bool UpdateEntity()
		{
			ReportHeaderDAO dao = (ReportHeaderDAO)CreateDAOInstance();
			return dao.UpdateExisting(base.Fields, base.Transaction);
		}
		
		/// <summary> Performs the update action of an existing Entity to the persistent storage.</summary>
		/// <param name="updateRestriction">Predicate expression, meant for concurrency checks in an Update query</param>
		/// <returns>true if succeeded, false otherwise</returns>
		protected override bool UpdateEntity(IPredicate updateRestriction)
		{
			ReportHeaderDAO dao = (ReportHeaderDAO)CreateDAOInstance();
			return dao.UpdateExisting(base.Fields, base.Transaction, updateRestriction);
		}
	
		/// <summary> Initializes the class with empty data, as if it is a new Entity.</summary>
		/// <param name="validatorToUse">Validator to use.</param>
		protected virtual void InitClassEmpty(IValidator validatorToUse)
		{
			OnInitializing();
			base.Fields = CreateFields();
			base.IsNew=true;
			base.Validator = validatorToUse;

			InitClassMembers();
			
			// __LLBLGENPRO_USER_CODE_REGION_START InitClassEmpty
			// __LLBLGENPRO_USER_CODE_REGION_END

			OnInitialized();
		}
		
		/// <summary>Creates entity fields object for this entity. Used in constructor to setup this entity in a polymorphic scenario.</summary>
		protected virtual IEntityFields CreateFields()
		{
			return EntityFieldsFactory.CreateEntityFieldsObject(CARMSData.EntityType.ReportHeaderEntity);
		}
		
		/// <summary>Creates a new transaction object</summary>
		/// <param name="levelOfIsolation">The level of isolation.</param>
		/// <param name="name">The name.</param>
		protected override ITransaction CreateTransaction( IsolationLevel levelOfIsolation, string name )
		{
			return new Transaction(levelOfIsolation, name);
		}

		/// <summary>
		/// Creates the ITypeDefaultValue instance used to provide default values for value types which aren't of type nullable(of T)
		/// </summary>
		/// <returns></returns>
		protected override ITypeDefaultValue CreateTypeDefaultValueProvider()
		{
			return new TypeDefaultValue();
		}

		/// <summary>
		/// Gets all related data objects, stored by name. The name is the field name mapped onto the relation for that particular data element. 
		/// </summary>
		/// <returns>Dictionary with per name the related referenced data element, which can be an entity collection or an entity or null</returns>
		public override Dictionary<string, object> GetRelatedData()
		{
			Dictionary<string, object> toReturn = new Dictionary<string, object>();
			toReturn.Add("ReportCategory", _reportCategory);
			toReturn.Add("ReportFlow", _reportFlow);
			toReturn.Add("User", _user);
			toReturn.Add("Message", _message);
			toReturn.Add("ReportValue", _reportValue);
			toReturn.Add("ReportPropertyCollectionViaReportValue", _reportPropertyCollectionViaReportValue);
			toReturn.Add("TemplateCollectionViaMessage", _templateCollectionViaMessage);
			toReturn.Add("UserCollectionViaMessage", _userCollectionViaMessage);

			return toReturn;
		}
		

		/// <summary> Initializes the the entity and fetches the data related to the entity in this entity.</summary>
		/// <param name="reportHeaderId">PK value for ReportHeader which data should be fetched into this ReportHeader object</param>
		/// <param name="validator">The validator object for this ReportHeaderEntity</param>
		/// <param name="prefetchPathToUse">the PrefetchPath which defines the graph of objects to fetch as well</param>
		protected virtual void InitClassFetch(System.Int32 reportHeaderId, IValidator validator, IPrefetchPath prefetchPathToUse)
		{
			OnInitializing();
			base.Validator = validator;
			InitClassMembers();
			base.Fields = CreateFields();
			bool wasSuccesful = Fetch(reportHeaderId, prefetchPathToUse, null, null);
			base.IsNew = !wasSuccesful;

			
			// __LLBLGENPRO_USER_CODE_REGION_START InitClassFetch
			// __LLBLGENPRO_USER_CODE_REGION_END

			OnInitialized();
		}

		/// <summary> Initializes the class members</summary>
		private void InitClassMembers()
		{
			_message = new CARMSData.CollectionClasses.MessageCollection(new MessageEntityFactory());
			_message.SetContainingEntityInfo(this, "ReportHeader");
			_alwaysFetchMessage = false;
			_alreadyFetchedMessage = false;
			_reportValue = new CARMSData.CollectionClasses.ReportValueCollection(new ReportValueEntityFactory());
			_reportValue.SetContainingEntityInfo(this, "ReportHeader");
			_alwaysFetchReportValue = false;
			_alreadyFetchedReportValue = false;
			_reportPropertyCollectionViaReportValue = new CARMSData.CollectionClasses.ReportPropertyCollection(new ReportPropertyEntityFactory());
			_alwaysFetchReportPropertyCollectionViaReportValue = false;
			_alreadyFetchedReportPropertyCollectionViaReportValue = false;
			_templateCollectionViaMessage = new CARMSData.CollectionClasses.TemplateCollection(new TemplateEntityFactory());
			_alwaysFetchTemplateCollectionViaMessage = false;
			_alreadyFetchedTemplateCollectionViaMessage = false;
			_userCollectionViaMessage = new CARMSData.CollectionClasses.UserCollection(new UserEntityFactory());
			_alwaysFetchUserCollectionViaMessage = false;
			_alreadyFetchedUserCollectionViaMessage = false;
			_reportCategory = null;
			_reportCategoryReturnsNewIfNotFound = true;
			_alwaysFetchReportCategory = false;
			_alreadyFetchedReportCategory = false;
			_reportFlow = null;
			_reportFlowReturnsNewIfNotFound = true;
			_alwaysFetchReportFlow = false;
			_alreadyFetchedReportFlow = false;
			_user = null;
			_userReturnsNewIfNotFound = true;
			_alwaysFetchUser = false;
			_alreadyFetchedUser = false;


			PerformDependencyInjection();
			
			// __LLBLGENPRO_USER_CODE_REGION_START InitClassMembers
			// __LLBLGENPRO_USER_CODE_REGION_END
			OnInitClassMembersComplete();
		}

		#region Custom Property Hashtable Setup
		/// <summary> Initializes the hashtables for the entity type and entity field custom properties. </summary>
		private static void SetupCustomPropertyHashtables()
		{
			_customProperties = new Dictionary<string, string>();
			_fieldsCustomProperties = new Dictionary<string, Dictionary<string, string>>();

			Dictionary<string, string> fieldHashtable = null;
			fieldHashtable = new Dictionary<string, string>();

			_fieldsCustomProperties.Add("ReportHeaderId", fieldHashtable);
			fieldHashtable = new Dictionary<string, string>();

			_fieldsCustomProperties.Add("ReportCategoryId", fieldHashtable);
			fieldHashtable = new Dictionary<string, string>();

			_fieldsCustomProperties.Add("CreateDate", fieldHashtable);
			fieldHashtable = new Dictionary<string, string>();

			_fieldsCustomProperties.Add("ApplyUserId", fieldHashtable);
			fieldHashtable = new Dictionary<string, string>();

			_fieldsCustomProperties.Add("TargetUserId", fieldHashtable);
			fieldHashtable = new Dictionary<string, string>();

			_fieldsCustomProperties.Add("CreationUrl", fieldHashtable);
			fieldHashtable = new Dictionary<string, string>();

			_fieldsCustomProperties.Add("ViewUrl", fieldHashtable);
			fieldHashtable = new Dictionary<string, string>();

			_fieldsCustomProperties.Add("Status", fieldHashtable);
			fieldHashtable = new Dictionary<string, string>();

			_fieldsCustomProperties.Add("IsActive", fieldHashtable);
			fieldHashtable = new Dictionary<string, string>();

			_fieldsCustomProperties.Add("Comment", fieldHashtable);
			fieldHashtable = new Dictionary<string, string>();

			_fieldsCustomProperties.Add("ReportCode", fieldHashtable);
			fieldHashtable = new Dictionary<string, string>();

			_fieldsCustomProperties.Add("ReportFlowId", fieldHashtable);
		}
		#endregion


		/// <summary> Removes the sync logic for member _reportCategory</summary>
		/// <param name="signalRelatedEntity">If set to true, it will call the related entity's UnsetRelatedEntity method</param>
		/// <param name="resetFKFields">if set to true it will also reset the FK fields pointing to the related entity</param>
		private void DesetupSyncReportCategory(bool signalRelatedEntity, bool resetFKFields)
		{
			base.PerformDesetupSyncRelatedEntity( _reportCategory, new PropertyChangedEventHandler( OnReportCategoryPropertyChanged ), "ReportCategory", ReportHeaderEntity.Relations.ReportCategoryEntityUsingReportCategoryId, true, signalRelatedEntity, "ReportHeader", resetFKFields, new int[] { (int)ReportHeaderFieldIndex.ReportCategoryId } );		
			_reportCategory = null;
		}
		
		/// <summary> setups the sync logic for member _reportCategory</summary>
		/// <param name="relatedEntity">Instance to set as the related entity of type entityType</param>
		private void SetupSyncReportCategory(IEntity relatedEntity)
		{
			if(_reportCategory!=relatedEntity)
			{		
				DesetupSyncReportCategory(true, true);
				_reportCategory = (ReportCategoryEntity)relatedEntity;
				base.PerformSetupSyncRelatedEntity( _reportCategory, new PropertyChangedEventHandler( OnReportCategoryPropertyChanged ), "ReportCategory", ReportHeaderEntity.Relations.ReportCategoryEntityUsingReportCategoryId, true, ref _alreadyFetchedReportCategory, new string[] {  } );
			}
		}

		/// <summary>Handles property change events of properties in a related entity.</summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void OnReportCategoryPropertyChanged( object sender, PropertyChangedEventArgs e )
		{
			switch( e.PropertyName )
			{
				default:
					break;
			}
		}

		/// <summary> Removes the sync logic for member _reportFlow</summary>
		/// <param name="signalRelatedEntity">If set to true, it will call the related entity's UnsetRelatedEntity method</param>
		/// <param name="resetFKFields">if set to true it will also reset the FK fields pointing to the related entity</param>
		private void DesetupSyncReportFlow(bool signalRelatedEntity, bool resetFKFields)
		{
			base.PerformDesetupSyncRelatedEntity( _reportFlow, new PropertyChangedEventHandler( OnReportFlowPropertyChanged ), "ReportFlow", ReportHeaderEntity.Relations.ReportFlowEntityUsingReportFlowId, true, signalRelatedEntity, "ReportHeader", resetFKFields, new int[] { (int)ReportHeaderFieldIndex.ReportFlowId } );		
			_reportFlow = null;
		}
		
		/// <summary> setups the sync logic for member _reportFlow</summary>
		/// <param name="relatedEntity">Instance to set as the related entity of type entityType</param>
		private void SetupSyncReportFlow(IEntity relatedEntity)
		{
			if(_reportFlow!=relatedEntity)
			{		
				DesetupSyncReportFlow(true, true);
				_reportFlow = (ReportFlowEntity)relatedEntity;
				base.PerformSetupSyncRelatedEntity( _reportFlow, new PropertyChangedEventHandler( OnReportFlowPropertyChanged ), "ReportFlow", ReportHeaderEntity.Relations.ReportFlowEntityUsingReportFlowId, true, ref _alreadyFetchedReportFlow, new string[] {  } );
			}
		}

		/// <summary>Handles property change events of properties in a related entity.</summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void OnReportFlowPropertyChanged( object sender, PropertyChangedEventArgs e )
		{
			switch( e.PropertyName )
			{
				default:
					break;
			}
		}

		/// <summary> Removes the sync logic for member _user</summary>
		/// <param name="signalRelatedEntity">If set to true, it will call the related entity's UnsetRelatedEntity method</param>
		/// <param name="resetFKFields">if set to true it will also reset the FK fields pointing to the related entity</param>
		private void DesetupSyncUser(bool signalRelatedEntity, bool resetFKFields)
		{
			base.PerformDesetupSyncRelatedEntity( _user, new PropertyChangedEventHandler( OnUserPropertyChanged ), "User", ReportHeaderEntity.Relations.UserEntityUsingApplyUserId, true, signalRelatedEntity, "ReportHeader", resetFKFields, new int[] { (int)ReportHeaderFieldIndex.ApplyUserId } );		
			_user = null;
		}
		
		/// <summary> setups the sync logic for member _user</summary>
		/// <param name="relatedEntity">Instance to set as the related entity of type entityType</param>
		private void SetupSyncUser(IEntity relatedEntity)
		{
			if(_user!=relatedEntity)
			{		
				DesetupSyncUser(true, true);
				_user = (UserEntity)relatedEntity;
				base.PerformSetupSyncRelatedEntity( _user, new PropertyChangedEventHandler( OnUserPropertyChanged ), "User", ReportHeaderEntity.Relations.UserEntityUsingApplyUserId, true, ref _alreadyFetchedUser, new string[] {  } );
			}
		}

		/// <summary>Handles property change events of properties in a related entity.</summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void OnUserPropertyChanged( object sender, PropertyChangedEventArgs e )
		{
			switch( e.PropertyName )
			{
				default:
					break;
			}
		}


		/// <summary> Fetches the entity from the persistent storage. Fetch simply reads the entity into an EntityFields object. </summary>
		/// <param name="reportHeaderId">PK value for ReportHeader which data should be fetched into this ReportHeader object</param>
		/// <param name="prefetchPathToUse">the PrefetchPath which defines the graph of objects to fetch as well</param>
		/// <param name="contextToUse">The context to add the entity to if the fetch was succesful. </param>
		/// <param name="excludedIncludedFields">The list of IEntityField objects which have to be excluded or included for the fetch. 
		/// If null or empty, all fields are fetched (default). If an instance of ExcludeIncludeFieldsList is passed in and its ExcludeContainedFields property
		/// is set to false, the fields contained in excludedIncludedFields are kept in the query, the rest of the fields in the query are excluded.</param>
		/// <returns>True if succeeded, false otherwise.</returns>
		private bool Fetch(System.Int32 reportHeaderId, IPrefetchPath prefetchPathToUse, Context contextToUse, ExcludeIncludeFieldsList excludedIncludedFields)
		{
			try
			{
				OnFetch();
				IDao dao = this.CreateDAOInstance();
				base.Fields[(int)ReportHeaderFieldIndex.ReportHeaderId].ForcedCurrentValueWrite(reportHeaderId);
				dao.FetchExisting(this, base.Transaction, prefetchPathToUse, contextToUse, excludedIncludedFields);
				return (base.Fields.State == EntityState.Fetched);
			}
			finally
			{
				OnFetchComplete();
			}
		}


		/// <summary> Creates the DAO instance for this type</summary>
		/// <returns></returns>
		protected override IDao CreateDAOInstance()
		{
			return DAOFactory.CreateReportHeaderDAO();
		}
		
		/// <summary> Creates the entity factory for this type.</summary>
		/// <returns></returns>
		protected override IEntityFactory CreateEntityFactory()
		{
			return new ReportHeaderEntityFactory();
		}

		#region Class Property Declarations
		/// <summary> The relations object holding all relations of this entity with other entity classes.</summary>
		public  static ReportHeaderRelations Relations
		{
			get	{ return new ReportHeaderRelations(); }
		}
		
		/// <summary> The custom properties for this entity type.</summary>
		/// <remarks>The data returned from this property should be considered read-only: it is not thread safe to alter this data at runtime.</remarks>
		public  static Dictionary<string, string> CustomProperties
		{
			get { return _customProperties;}
		}


		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'Message' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathMessage
		{
			get
			{
				return new PrefetchPathElement(new CARMSData.CollectionClasses.MessageCollection(),
					(IEntityRelation)GetRelationsForField("Message")[0], (int)CARMSData.EntityType.ReportHeaderEntity, (int)CARMSData.EntityType.MessageEntity, 0, null, null, null, "Message", SD.LLBLGen.Pro.ORMSupportClasses.RelationType.OneToMany);
			}
		}

		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'ReportValue' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathReportValue
		{
			get
			{
				return new PrefetchPathElement(new CARMSData.CollectionClasses.ReportValueCollection(),
					(IEntityRelation)GetRelationsForField("ReportValue")[0], (int)CARMSData.EntityType.ReportHeaderEntity, (int)CARMSData.EntityType.ReportValueEntity, 0, null, null, null, "ReportValue", SD.LLBLGen.Pro.ORMSupportClasses.RelationType.OneToMany);
			}
		}

		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'ReportProperty' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathReportPropertyCollectionViaReportValue
		{
			get
			{
				IEntityRelation intermediateRelation = ReportHeaderEntity.Relations.ReportValueEntityUsingReportHeaderId;
				intermediateRelation.SetAliases(string.Empty, "ReportValue_");
				return new PrefetchPathElement(new CARMSData.CollectionClasses.ReportPropertyCollection(), intermediateRelation,
					(int)CARMSData.EntityType.ReportHeaderEntity, (int)CARMSData.EntityType.ReportPropertyEntity, 0, null, null, GetRelationsForField("ReportPropertyCollectionViaReportValue"), "ReportPropertyCollectionViaReportValue", SD.LLBLGen.Pro.ORMSupportClasses.RelationType.ManyToMany);
			}
		}

		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'Template' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathTemplateCollectionViaMessage
		{
			get
			{
				IEntityRelation intermediateRelation = ReportHeaderEntity.Relations.MessageEntityUsingReportHeaderId;
				intermediateRelation.SetAliases(string.Empty, "Message_");
				return new PrefetchPathElement(new CARMSData.CollectionClasses.TemplateCollection(), intermediateRelation,
					(int)CARMSData.EntityType.ReportHeaderEntity, (int)CARMSData.EntityType.TemplateEntity, 0, null, null, GetRelationsForField("TemplateCollectionViaMessage"), "TemplateCollectionViaMessage", SD.LLBLGen.Pro.ORMSupportClasses.RelationType.ManyToMany);
			}
		}

		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'User' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathUserCollectionViaMessage
		{
			get
			{
				IEntityRelation intermediateRelation = ReportHeaderEntity.Relations.MessageEntityUsingReportHeaderId;
				intermediateRelation.SetAliases(string.Empty, "Message_");
				return new PrefetchPathElement(new CARMSData.CollectionClasses.UserCollection(), intermediateRelation,
					(int)CARMSData.EntityType.ReportHeaderEntity, (int)CARMSData.EntityType.UserEntity, 0, null, null, GetRelationsForField("UserCollectionViaMessage"), "UserCollectionViaMessage", SD.LLBLGen.Pro.ORMSupportClasses.RelationType.ManyToMany);
			}
		}

		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'ReportCategory' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathReportCategory
		{
			get
			{
				return new PrefetchPathElement(new CARMSData.CollectionClasses.ReportCategoryCollection(),
					(IEntityRelation)GetRelationsForField("ReportCategory")[0], (int)CARMSData.EntityType.ReportHeaderEntity, (int)CARMSData.EntityType.ReportCategoryEntity, 0, null, null, null, "ReportCategory", SD.LLBLGen.Pro.ORMSupportClasses.RelationType.ManyToOne);
			}
		}

		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'ReportFlow' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathReportFlow
		{
			get
			{
				return new PrefetchPathElement(new CARMSData.CollectionClasses.ReportFlowCollection(),
					(IEntityRelation)GetRelationsForField("ReportFlow")[0], (int)CARMSData.EntityType.ReportHeaderEntity, (int)CARMSData.EntityType.ReportFlowEntity, 0, null, null, null, "ReportFlow", SD.LLBLGen.Pro.ORMSupportClasses.RelationType.ManyToOne);
			}
		}

		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'User' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathUser
		{
			get
			{
				return new PrefetchPathElement(new CARMSData.CollectionClasses.UserCollection(),
					(IEntityRelation)GetRelationsForField("User")[0], (int)CARMSData.EntityType.ReportHeaderEntity, (int)CARMSData.EntityType.UserEntity, 0, null, null, null, "User", SD.LLBLGen.Pro.ORMSupportClasses.RelationType.ManyToOne);
			}
		}


		/// <summary>Returns the full name for this entity, which is important for the DAO to find back persistence info for this entity.</summary>
		[Browsable(false), XmlIgnore]
		public override string LLBLGenProEntityName
		{
			get { return "ReportHeaderEntity";}
		}

		/// <summary> The custom properties for the type of this entity instance.</summary>
		/// <remarks>The data returned from this property should be considered read-only: it is not thread safe to alter this data at runtime.</remarks>
		[Browsable(false), XmlIgnore]
		public override Dictionary<string, string> CustomPropertiesOfType
		{
			get { return ReportHeaderEntity.CustomProperties;}
		}

		/// <summary> The custom properties for the fields of this entity type. The returned Hashtable contains per fieldname a hashtable of name-value pairs. </summary>
		/// <remarks>The data returned from this property should be considered read-only: it is not thread safe to alter this data at runtime.</remarks>
		public  static Dictionary<string, Dictionary<string, string>> FieldsCustomProperties
		{
			get { return _fieldsCustomProperties;}
		}

		/// <summary> The custom properties for the fields of the type of this entity instance. The returned Hashtable contains per fieldname a hashtable of name-value pairs. </summary>
		/// <remarks>The data returned from this property should be considered read-only: it is not thread safe to alter this data at runtime.</remarks>
		[Browsable(false), XmlIgnore]
		public override Dictionary<string, Dictionary<string, string>> FieldsCustomPropertiesOfType
		{
			get { return ReportHeaderEntity.FieldsCustomProperties;}
		}

		/// <summary> The ReportHeaderId property of the Entity ReportHeader<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "ReportHeader"."ReportHeaderID"<br/>
		/// Table field type characteristics (type, precision, scale, length): Int, 10, 0, 0<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): false, true, true</remarks>
		public virtual System.Int32 ReportHeaderId
		{
			get { return (System.Int32)GetValue((int)ReportHeaderFieldIndex.ReportHeaderId, true); }
			set	{ SetValue((int)ReportHeaderFieldIndex.ReportHeaderId, value, true); }
		}
		/// <summary> The ReportCategoryId property of the Entity ReportHeader<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "ReportHeader"."ReportCategoryID"<br/>
		/// Table field type characteristics (type, precision, scale, length): Int, 10, 0, 0<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): false, false, false</remarks>
		public virtual System.Int32 ReportCategoryId
		{
			get { return (System.Int32)GetValue((int)ReportHeaderFieldIndex.ReportCategoryId, true); }
			set	{ SetValue((int)ReportHeaderFieldIndex.ReportCategoryId, value, true); }
		}
		/// <summary> The CreateDate property of the Entity ReportHeader<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "ReportHeader"."CreateDate"<br/>
		/// Table field type characteristics (type, precision, scale, length): DateTime, 0, 0, 0<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): false, false, false</remarks>
		public virtual System.DateTime CreateDate
		{
			get { return (System.DateTime)GetValue((int)ReportHeaderFieldIndex.CreateDate, true); }
			set	{ SetValue((int)ReportHeaderFieldIndex.CreateDate, value, true); }
		}
		/// <summary> The ApplyUserId property of the Entity ReportHeader<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "ReportHeader"."ApplyUserID"<br/>
		/// Table field type characteristics (type, precision, scale, length): Int, 10, 0, 0<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): false, false, false</remarks>
		public virtual System.Int32 ApplyUserId
		{
			get { return (System.Int32)GetValue((int)ReportHeaderFieldIndex.ApplyUserId, true); }
			set	{ SetValue((int)ReportHeaderFieldIndex.ApplyUserId, value, true); }
		}
		/// <summary> The TargetUserId property of the Entity ReportHeader<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "ReportHeader"."TargetUserID"<br/>
		/// Table field type characteristics (type, precision, scale, length): Int, 10, 0, 0<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): false, false, false</remarks>
		public virtual System.Int32 TargetUserId
		{
			get { return (System.Int32)GetValue((int)ReportHeaderFieldIndex.TargetUserId, true); }
			set	{ SetValue((int)ReportHeaderFieldIndex.TargetUserId, value, true); }
		}
		/// <summary> The CreationUrl property of the Entity ReportHeader<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "ReportHeader"."CreationUrl"<br/>
		/// Table field type characteristics (type, precision, scale, length): NVarChar, 0, 0, 200<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): false, false, false</remarks>
		public virtual System.String CreationUrl
		{
			get { return (System.String)GetValue((int)ReportHeaderFieldIndex.CreationUrl, true); }
			set	{ SetValue((int)ReportHeaderFieldIndex.CreationUrl, value, true); }
		}
		/// <summary> The ViewUrl property of the Entity ReportHeader<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "ReportHeader"."ViewUrl"<br/>
		/// Table field type characteristics (type, precision, scale, length): NVarChar, 0, 0, 200<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.String ViewUrl
		{
			get { return (System.String)GetValue((int)ReportHeaderFieldIndex.ViewUrl, true); }
			set	{ SetValue((int)ReportHeaderFieldIndex.ViewUrl, value, true); }
		}
		/// <summary> The Status property of the Entity ReportHeader<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "ReportHeader"."Status"<br/>
		/// Table field type characteristics (type, precision, scale, length): Int, 10, 0, 0<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): false, false, false</remarks>
		public virtual System.Int32 Status
		{
			get { return (System.Int32)GetValue((int)ReportHeaderFieldIndex.Status, true); }
			set	{ SetValue((int)ReportHeaderFieldIndex.Status, value, true); }
		}
		/// <summary> The IsActive property of the Entity ReportHeader<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "ReportHeader"."IsActive"<br/>
		/// Table field type characteristics (type, precision, scale, length): Bit, 0, 0, 0<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): false, false, false</remarks>
		public virtual System.Boolean IsActive
		{
			get { return (System.Boolean)GetValue((int)ReportHeaderFieldIndex.IsActive, true); }
			set	{ SetValue((int)ReportHeaderFieldIndex.IsActive, value, true); }
		}
		/// <summary> The Comment property of the Entity ReportHeader<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "ReportHeader"."Comment"<br/>
		/// Table field type characteristics (type, precision, scale, length): NText, 0, 0, 1073741823<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.String Comment
		{
			get { return (System.String)GetValue((int)ReportHeaderFieldIndex.Comment, true); }
			set	{ SetValue((int)ReportHeaderFieldIndex.Comment, value, true); }
		}
		/// <summary> The ReportCode property of the Entity ReportHeader<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "ReportHeader"."ReportCode"<br/>
		/// Table field type characteristics (type, precision, scale, length): NVarChar, 0, 0, 50<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): false, false, false</remarks>
		public virtual System.String ReportCode
		{
			get { return (System.String)GetValue((int)ReportHeaderFieldIndex.ReportCode, true); }
			set	{ SetValue((int)ReportHeaderFieldIndex.ReportCode, value, true); }
		}
		/// <summary> The ReportFlowId property of the Entity ReportHeader<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "ReportHeader"."ReportFlowID"<br/>
		/// Table field type characteristics (type, precision, scale, length): UniqueIdentifier, 0, 0, 0<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual Nullable<System.Guid> ReportFlowId
		{
			get { return (Nullable<System.Guid>)GetValue((int)ReportHeaderFieldIndex.ReportFlowId, false); }
			set	{ SetValue((int)ReportHeaderFieldIndex.ReportFlowId, value, true); }
		}

		/// <summary> Retrieves all related entities of type 'MessageEntity' using a relation of type '1:n'.</summary>
		/// <remarks>This property is added for databinding conveniance, however it is recommeded to use the method 'GetMultiMessage()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the same scope.</remarks>
		public virtual CARMSData.CollectionClasses.MessageCollection Message
		{
			get	{ return GetMultiMessage(false); }
		}

		/// <summary> Gets / sets the lazy loading flag for Message. When set to true, Message is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time Message is accessed. You can always execute
		/// a forced fetch by calling GetMultiMessage(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchMessage
		{
			get	{ return _alwaysFetchMessage; }
			set	{ _alwaysFetchMessage = value; }	
		}		
				
		/// <summary>Gets / Sets the lazy loading flag if the property Message already has been fetched. Setting this property to false when Message has been fetched
		/// will clear the Message collection well. Setting this property to true while Message hasn't been fetched disables lazy loading for Message</summary>
		[Browsable(false)]
		public bool AlreadyFetchedMessage
		{
			get { return _alreadyFetchedMessage;}
			set 
			{
				if(_alreadyFetchedMessage && !value && (_message != null))
				{
					_message.Clear();
				}
				_alreadyFetchedMessage = value;
			}
		}
		/// <summary> Retrieves all related entities of type 'ReportValueEntity' using a relation of type '1:n'.</summary>
		/// <remarks>This property is added for databinding conveniance, however it is recommeded to use the method 'GetMultiReportValue()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the same scope.</remarks>
		public virtual CARMSData.CollectionClasses.ReportValueCollection ReportValue
		{
			get	{ return GetMultiReportValue(false); }
		}

		/// <summary> Gets / sets the lazy loading flag for ReportValue. When set to true, ReportValue is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time ReportValue is accessed. You can always execute
		/// a forced fetch by calling GetMultiReportValue(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchReportValue
		{
			get	{ return _alwaysFetchReportValue; }
			set	{ _alwaysFetchReportValue = value; }	
		}		
				
		/// <summary>Gets / Sets the lazy loading flag if the property ReportValue already has been fetched. Setting this property to false when ReportValue has been fetched
		/// will clear the ReportValue collection well. Setting this property to true while ReportValue hasn't been fetched disables lazy loading for ReportValue</summary>
		[Browsable(false)]
		public bool AlreadyFetchedReportValue
		{
			get { return _alreadyFetchedReportValue;}
			set 
			{
				if(_alreadyFetchedReportValue && !value && (_reportValue != null))
				{
					_reportValue.Clear();
				}
				_alreadyFetchedReportValue = value;
			}
		}

		/// <summary> Retrieves all related entities of type 'ReportPropertyEntity' using a relation of type 'm:n'.</summary>
		/// <remarks>This property is added for databinding conveniance, however it is recommeded to use the method 'GetMultiReportPropertyCollectionViaReportValue()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the same scope.</remarks>
		public virtual CARMSData.CollectionClasses.ReportPropertyCollection ReportPropertyCollectionViaReportValue
		{
			get { return GetMultiReportPropertyCollectionViaReportValue(false); }
		}

		/// <summary> Gets / sets the lazy loading flag for ReportPropertyCollectionViaReportValue. When set to true, ReportPropertyCollectionViaReportValue is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time ReportPropertyCollectionViaReportValue is accessed. You can always execute
		/// a forced fetch by calling GetMultiReportPropertyCollectionViaReportValue(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchReportPropertyCollectionViaReportValue
		{
			get	{ return _alwaysFetchReportPropertyCollectionViaReportValue; }
			set	{ _alwaysFetchReportPropertyCollectionViaReportValue = value; }
		}
				
		/// <summary>Gets / Sets the lazy loading flag if the property ReportPropertyCollectionViaReportValue already has been fetched. Setting this property to false when ReportPropertyCollectionViaReportValue has been fetched
		/// will clear the ReportPropertyCollectionViaReportValue collection well. Setting this property to true while ReportPropertyCollectionViaReportValue hasn't been fetched disables lazy loading for ReportPropertyCollectionViaReportValue</summary>
		[Browsable(false)]
		public bool AlreadyFetchedReportPropertyCollectionViaReportValue
		{
			get { return _alreadyFetchedReportPropertyCollectionViaReportValue;}
			set 
			{
				if(_alreadyFetchedReportPropertyCollectionViaReportValue && !value && (_reportPropertyCollectionViaReportValue != null))
				{
					_reportPropertyCollectionViaReportValue.Clear();
				}
				_alreadyFetchedReportPropertyCollectionViaReportValue = value;
			}
		}
		/// <summary> Retrieves all related entities of type 'TemplateEntity' using a relation of type 'm:n'.</summary>
		/// <remarks>This property is added for databinding conveniance, however it is recommeded to use the method 'GetMultiTemplateCollectionViaMessage()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the same scope.</remarks>
		public virtual CARMSData.CollectionClasses.TemplateCollection TemplateCollectionViaMessage
		{
			get { return GetMultiTemplateCollectionViaMessage(false); }
		}

		/// <summary> Gets / sets the lazy loading flag for TemplateCollectionViaMessage. When set to true, TemplateCollectionViaMessage is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time TemplateCollectionViaMessage is accessed. You can always execute
		/// a forced fetch by calling GetMultiTemplateCollectionViaMessage(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchTemplateCollectionViaMessage
		{
			get	{ return _alwaysFetchTemplateCollectionViaMessage; }
			set	{ _alwaysFetchTemplateCollectionViaMessage = value; }
		}
				
		/// <summary>Gets / Sets the lazy loading flag if the property TemplateCollectionViaMessage already has been fetched. Setting this property to false when TemplateCollectionViaMessage has been fetched
		/// will clear the TemplateCollectionViaMessage collection well. Setting this property to true while TemplateCollectionViaMessage hasn't been fetched disables lazy loading for TemplateCollectionViaMessage</summary>
		[Browsable(false)]
		public bool AlreadyFetchedTemplateCollectionViaMessage
		{
			get { return _alreadyFetchedTemplateCollectionViaMessage;}
			set 
			{
				if(_alreadyFetchedTemplateCollectionViaMessage && !value && (_templateCollectionViaMessage != null))
				{
					_templateCollectionViaMessage.Clear();
				}
				_alreadyFetchedTemplateCollectionViaMessage = value;
			}
		}
		/// <summary> Retrieves all related entities of type 'UserEntity' using a relation of type 'm:n'.</summary>
		/// <remarks>This property is added for databinding conveniance, however it is recommeded to use the method 'GetMultiUserCollectionViaMessage()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the same scope.</remarks>
		public virtual CARMSData.CollectionClasses.UserCollection UserCollectionViaMessage
		{
			get { return GetMultiUserCollectionViaMessage(false); }
		}

		/// <summary> Gets / sets the lazy loading flag for UserCollectionViaMessage. When set to true, UserCollectionViaMessage is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time UserCollectionViaMessage is accessed. You can always execute
		/// a forced fetch by calling GetMultiUserCollectionViaMessage(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchUserCollectionViaMessage
		{
			get	{ return _alwaysFetchUserCollectionViaMessage; }
			set	{ _alwaysFetchUserCollectionViaMessage = value; }
		}
				
		/// <summary>Gets / Sets the lazy loading flag if the property UserCollectionViaMessage already has been fetched. Setting this property to false when UserCollectionViaMessage has been fetched
		/// will clear the UserCollectionViaMessage collection well. Setting this property to true while UserCollectionViaMessage hasn't been fetched disables lazy loading for UserCollectionViaMessage</summary>
		[Browsable(false)]
		public bool AlreadyFetchedUserCollectionViaMessage
		{
			get { return _alreadyFetchedUserCollectionViaMessage;}
			set 
			{
				if(_alreadyFetchedUserCollectionViaMessage && !value && (_userCollectionViaMessage != null))
				{
					_userCollectionViaMessage.Clear();
				}
				_alreadyFetchedUserCollectionViaMessage = value;
			}
		}

		/// <summary> Gets / sets related entity of type 'ReportCategoryEntity'. This property is not visible in databound grids.
		/// Setting this property to a new object will make the load-on-demand feature to stop fetching data from the database, until you set this
		/// property to null. Setting this property to an entity will make sure that FK-PK relations are synchronized when appropriate.</summary>
		/// <remarks>This property is added for conveniance, however it is recommeded to use the method 'GetSingleReportCategory()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the
		/// same scope. The property is marked non-browsable to make it hidden in bound controls, f.e. datagrids.</remarks>
		[Browsable(false)]
		public virtual ReportCategoryEntity ReportCategory
		{
			get	{ return GetSingleReportCategory(false); }
			set
			{
				if(base.IsDeserializing)
				{
					SetupSyncReportCategory(value);
				}
				else
				{
					if(value==null)
					{
						if(_reportCategory != null)
						{
							_reportCategory.UnsetRelatedEntity(this, "ReportHeader");
						}
					}
					else
					{
						if(_reportCategory!=value)
						{
							((IEntity)value).SetRelatedEntity(this, "ReportHeader");
						}
					}
				}
			}
		}

		/// <summary> Gets / sets the lazy loading flag for ReportCategory. When set to true, ReportCategory is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time ReportCategory is accessed. You can always execute
		/// a forced fetch by calling GetSingleReportCategory(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchReportCategory
		{
			get	{ return _alwaysFetchReportCategory; }
			set	{ _alwaysFetchReportCategory = value; }	
		}
				
		/// <summary>Gets / Sets the lazy loading flag if the property ReportCategory already has been fetched. Setting this property to false when ReportCategory has been fetched
		/// will set ReportCategory to null as well. Setting this property to true while ReportCategory hasn't been fetched disables lazy loading for ReportCategory</summary>
		[Browsable(false)]
		public bool AlreadyFetchedReportCategory
		{
			get { return _alreadyFetchedReportCategory;}
			set 
			{
				if(_alreadyFetchedReportCategory && !value)
				{
					this.ReportCategory = null;
				}
				_alreadyFetchedReportCategory = value;
			}
		}

		/// <summary> Gets / sets the flag for what to do if the related entity available through the property ReportCategory is not found
		/// in the database. When set to true, ReportCategory will return a new entity instance if the related entity is not found, otherwise 
		/// null be returned if the related entity is not found. Default: true.</summary>
		[Browsable(false)]
		public bool ReportCategoryReturnsNewIfNotFound
		{
			get	{ return _reportCategoryReturnsNewIfNotFound; }
			set { _reportCategoryReturnsNewIfNotFound = value; }	
		}
		/// <summary> Gets / sets related entity of type 'ReportFlowEntity'. This property is not visible in databound grids.
		/// Setting this property to a new object will make the load-on-demand feature to stop fetching data from the database, until you set this
		/// property to null. Setting this property to an entity will make sure that FK-PK relations are synchronized when appropriate.</summary>
		/// <remarks>This property is added for conveniance, however it is recommeded to use the method 'GetSingleReportFlow()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the
		/// same scope. The property is marked non-browsable to make it hidden in bound controls, f.e. datagrids.</remarks>
		[Browsable(false)]
		public virtual ReportFlowEntity ReportFlow
		{
			get	{ return GetSingleReportFlow(false); }
			set
			{
				if(base.IsDeserializing)
				{
					SetupSyncReportFlow(value);
				}
				else
				{
					if(value==null)
					{
						if(_reportFlow != null)
						{
							_reportFlow.UnsetRelatedEntity(this, "ReportHeader");
						}
					}
					else
					{
						if(_reportFlow!=value)
						{
							((IEntity)value).SetRelatedEntity(this, "ReportHeader");
						}
					}
				}
			}
		}

		/// <summary> Gets / sets the lazy loading flag for ReportFlow. When set to true, ReportFlow is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time ReportFlow is accessed. You can always execute
		/// a forced fetch by calling GetSingleReportFlow(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchReportFlow
		{
			get	{ return _alwaysFetchReportFlow; }
			set	{ _alwaysFetchReportFlow = value; }	
		}
				
		/// <summary>Gets / Sets the lazy loading flag if the property ReportFlow already has been fetched. Setting this property to false when ReportFlow has been fetched
		/// will set ReportFlow to null as well. Setting this property to true while ReportFlow hasn't been fetched disables lazy loading for ReportFlow</summary>
		[Browsable(false)]
		public bool AlreadyFetchedReportFlow
		{
			get { return _alreadyFetchedReportFlow;}
			set 
			{
				if(_alreadyFetchedReportFlow && !value)
				{
					this.ReportFlow = null;
				}
				_alreadyFetchedReportFlow = value;
			}
		}

		/// <summary> Gets / sets the flag for what to do if the related entity available through the property ReportFlow is not found
		/// in the database. When set to true, ReportFlow will return a new entity instance if the related entity is not found, otherwise 
		/// null be returned if the related entity is not found. Default: true.</summary>
		[Browsable(false)]
		public bool ReportFlowReturnsNewIfNotFound
		{
			get	{ return _reportFlowReturnsNewIfNotFound; }
			set { _reportFlowReturnsNewIfNotFound = value; }	
		}
		/// <summary> Gets / sets related entity of type 'UserEntity'. This property is not visible in databound grids.
		/// Setting this property to a new object will make the load-on-demand feature to stop fetching data from the database, until you set this
		/// property to null. Setting this property to an entity will make sure that FK-PK relations are synchronized when appropriate.</summary>
		/// <remarks>This property is added for conveniance, however it is recommeded to use the method 'GetSingleUser()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the
		/// same scope. The property is marked non-browsable to make it hidden in bound controls, f.e. datagrids.</remarks>
		[Browsable(false)]
		public virtual UserEntity User
		{
			get	{ return GetSingleUser(false); }
			set
			{
				if(base.IsDeserializing)
				{
					SetupSyncUser(value);
				}
				else
				{
					if(value==null)
					{
						if(_user != null)
						{
							_user.UnsetRelatedEntity(this, "ReportHeader");
						}
					}
					else
					{
						if(_user!=value)
						{
							((IEntity)value).SetRelatedEntity(this, "ReportHeader");
						}
					}
				}
			}
		}

		/// <summary> Gets / sets the lazy loading flag for User. When set to true, User is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time User is accessed. You can always execute
		/// a forced fetch by calling GetSingleUser(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchUser
		{
			get	{ return _alwaysFetchUser; }
			set	{ _alwaysFetchUser = value; }	
		}
				
		/// <summary>Gets / Sets the lazy loading flag if the property User already has been fetched. Setting this property to false when User has been fetched
		/// will set User to null as well. Setting this property to true while User hasn't been fetched disables lazy loading for User</summary>
		[Browsable(false)]
		public bool AlreadyFetchedUser
		{
			get { return _alreadyFetchedUser;}
			set 
			{
				if(_alreadyFetchedUser && !value)
				{
					this.User = null;
				}
				_alreadyFetchedUser = value;
			}
		}

		/// <summary> Gets / sets the flag for what to do if the related entity available through the property User is not found
		/// in the database. When set to true, User will return a new entity instance if the related entity is not found, otherwise 
		/// null be returned if the related entity is not found. Default: true.</summary>
		[Browsable(false)]
		public bool UserReturnsNewIfNotFound
		{
			get	{ return _userReturnsNewIfNotFound; }
			set { _userReturnsNewIfNotFound = value; }	
		}



		/// <summary> Gets or sets a value indicating whether this entity is a subtype</summary>
		protected override bool LLBLGenProIsSubType
		{
			get { return false;}
		}

		/// <summary> Gets the type of the hierarchy this entity is in. </summary>
		[System.ComponentModel.Browsable(false), XmlIgnore]
		protected override InheritanceHierarchyType LLBLGenProIsInHierarchyOfType
		{
			get { return InheritanceHierarchyType.None;}
		}
		
		/// <summary>Returns the CARMSData.EntityType enum value for this entity.</summary>
		[Browsable(false), XmlIgnore]
		public override int LLBLGenProEntityTypeValue 
		{ 
			get { return (int)CARMSData.EntityType.ReportHeaderEntity; }
		}
		#endregion


		#region Custom Entity code
		
		// __LLBLGENPRO_USER_CODE_REGION_START CustomEntityCode
		// __LLBLGENPRO_USER_CODE_REGION_END
		#endregion

		#region Included code

		#endregion
	}
}
